﻿@model Mvc4Learn.Models.ViewModels.AlbumViewModel
@{
    ViewBag.Title = "Edit";
    SelectList lstGenre = ViewBag.GenreId as SelectList;
    IEnumerable<SelectListItem>  lstArtist = ViewBag.ArtistId as IEnumerable<SelectListItem>;
}

<h2>Edit</h2>

@using (Html.BeginForm())
{

    <fieldset>
        <legend>Album</legend>

        @Html.HiddenFor(model => model.Album.AlbumId)

        <div class="editor-label">
            @Html.LabelFor(model => model.Album.GenreId, "Genre")
        </div>
        <div class="editor-field">
            @*            @Html.DropDownList("GenreId", String.Empty)*@
            @Html.DropDownListFor(model => model.Genre.GenreId, lstGenre)
            @Html.ValidationMessageFor(model => model.Album.GenreId)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Album.ArtistId, "Artist")
        </div>
        <div class="editor-field">
            @*            @Html.DropDownList("ArtistId", String.Empty)*@
            @Html.DropDownListFor(model => model.Artist.ArtistId, lstArtist)
            @Html.ValidationMessageFor(model => model.Album.ArtistId)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Album.Title)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Album.Title)
            @Html.ValidationMessageFor(model => model.Album.Title)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Album.Price)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Album.Price)
            @Html.ValidationMessageFor(model => model.Album.Price)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Album.AlbumArtUrl)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Album.AlbumArtUrl)
            @Html.ValidationMessageFor(model => model.Album.AlbumArtUrl)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>

        @*列出所有错误的验证消息*@
        @Html.ValidationSummary(excludePropertyErrors:true)

    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
